package designMode.commandPattern;

/**
 * @ClassName Test
 * @Description
 * @Author LIBOFEI
 * @Date 2020/6/24 21:50
 * @Version 1.0
 **/
public class Test {

    public static void main(String[] args) {
        SimpleRemoteControl remote = new SimpleRemoteControl();
        Light light = new Light();//灯具操作实例
        LightOnCommand lightOnCommand = new LightOnCommand(light);//开灯
        LightOffCommand lightOffCommand = new LightOffCommand(light);//关灯
        remote.setCommond(0,lightOnCommand,lightOffCommand);
        remote.onButtonWasPushed(0);
        remote.undoButtonWasPushes();
        remote.offButtonWasPushed(0);
        remote.undoButtonWasPushes();

        Stereo stereo = new Stereo();//音响
        StereoOnCommand stereoOnCommand = new StereoOnCommand(stereo);
        StereoOffCommand stereoOffCommand = new StereoOffCommand(stereo);
        remote.setCommond(1,stereoOnCommand,stereoOffCommand);
        remote.onButtonWasPushed(1);
        remote.offButtonWasPushed(1);

        Command[] ons = {lightOnCommand , stereoOnCommand};//全部
        Command[] ono = {lightOffCommand , stereoOffCommand};
        AllCommand allOnCommand = new AllCommand(ons);
        AllCommand allOffCommand = new AllCommand(ono);
        remote.setCommond(2,allOnCommand,allOffCommand);
        remote.onButtonWasPushed(2);
        remote.offButtonWasPushed(2);
    }
}
